package com.lyn.solitude.pluginhost.uitls

import java.io.BufferedReader
import java.io.InputStreamReader
import java.lang.StringBuilder


/**
 * @author longyn 2024/5/12
 * @version 1.0.0
 */
object ShellUtil {

    @JvmStatic
    fun shell(cmd: String): String? {
       try {
           val process = Runtime.getRuntime().exec(cmd)
           val inputStream = process.inputStream
           val bufferedReader = BufferedReader(InputStreamReader(inputStream))
           val stringStream = bufferedReader.lines()
           val sb = StringBuilder()
           stringStream.forEach {
               sb.append(it)
           }
           bufferedReader.close()
           return sb.toString()
       }catch (e:Throwable){
           e.printStackTrace()
       }
        return null
    }



}